using UnityEngine;

namespace AutoChess
{
    //unity 默认动画实现
   class UnityAnimatorInterface :AnimatorInterface
   {
       private Animator m_animator;
        
        public bool Create(ActorAnimator ownAnimator)
        {
            var display = ownAnimator.OwnActor.Display;
            m_animator = display.TryGetUnityAnimator();
            return true;
        }

        public void SetIntParam(int paramId, int val)
        {
            if (m_animator != null)
            {
                m_animator.SetInteger(paramId,val);
            }
        }

        public void SetBoolParam(int paramId, bool val)
        {
            if (m_animator != null)
            {
                m_animator.SetBool(paramId,val);
            }
        }

        public void SetTrigget(int triggerId)
        {
            if (m_animator != null)
            {
                m_animator.SetTrigger(triggerId);
            }
        }

        public void SetAnimCtrSpeed(float speed)
        {
            if (m_animator != null)
            {
                m_animator.speed = speed;
            }
        }

        public void PlayAnimator(string aniName)
        {
            if (m_animator != null)
            {
                m_animator.Play(aniName);
            }
        }

        public void PlayCrossFade(string aniName,float transitionDuration,int layer,float normalizedTime)
        {
            if (m_animator != null)
            {
                m_animator.CrossFade(aniName,transitionDuration,layer,normalizedTime);
            }
        }
   }
}